package IO流.对象流;

import java.io.*;

//序列化 字节到Java，Java到字节
public class ObjectOutputDemo {
    public static void main(String[] args) {
        ObjectOutputStream oos=null;
        try {
           oos=new ObjectOutputStream(new FileOutputStream("e:/dd4.txt"));
           User user=new User(1,"杨魁","18");
           oos.writeObject(user);
           oos.flush();

        }catch (Exception e){
            e.printStackTrace();
        }finally {
            try {
                if(oos!=null)oos.close();

            }catch (Exception e){
                e.printStackTrace();
            }
        }
    }
}



